home *** CD-ROM | disk | FTP | other *** search
/ Imagine the Universe (9th Edition) / Imagine the Universe 9 - Disc 1.iso / pc / imagine / docs / science / try_l2 / javascript / stars.js < prev    next >
Text File  |  2003-01-06  |  2KB  |  106 lines

  1. size1 = "Blank";
  2. size2 = "Blank";
  3. size3 = "Blank";
  4. size4 = "Blank";
  5. size5 = "Blank";
  6. size6 = "Blank";
  7.  
  8. function testButton(form) {
  9.         if (form.answer1)
  10.     size1 = form.answer1.selectedIndex;
  11.     if (form.answer2)
  12.     size2 = form.answer2.selectedIndex;
  13.     if (form.answer3)
  14.     size3 = form.answer3.selectedIndex;
  15.     if (form.answer4)
  16.     size4 = form.answer4.selectedIndex;
  17.     if (form.answer5)
  18.     size5 = form.answer5.selectedIndex;
  19.     if (form.answer6)
  20.     size6 = form.answer6.selectedIndex;
  21.  
  22.     RightAnswer1 = "6";
  23.     RightAnswer2 = "5";
  24.     RightAnswer3 = "4";
  25.     RightAnswer4 = "1";
  26.     RightAnswer5 = "2";
  27.     RightAnswer6 = "3";
  28.  
  29.     NumberCorrect = 0;
  30.     AnswerPage = 'stars_solution.html';
  31.     
  32.     if (size1 == RightAnswer1) {
  33.         NumberCorrect++;
  34.     }
  35.     if (size2 == RightAnswer2) {
  36.         NumberCorrect++;
  37.     }
  38.     if (size3 == RightAnswer3) {
  39.         NumberCorrect++;
  40.     }
  41.     if (size4 == RightAnswer4) {
  42.         NumberCorrect++;
  43.     }
  44.     if (size5 == RightAnswer5) {
  45.         NumberCorrect++;
  46.     }
  47.     if (size6 == RightAnswer6) {
  48.         NumberCorrect++;
  49.     }
  50.     
  51.     
  52.     alert ("You answered " +NumberCorrect + " out of 6 questions correctly!");
  53.     if (NumberCorrect==6) {
  54.         location = AnswerPage; 
  55.     }
  56. }
  57.  
  58. function answerButton(form) {
  59.         if (form.answer1)
  60.     size1 = form.answer1.selectedIndex;
  61.     if (form.answer2)
  62.     size2 = form.answer2.selectedIndex;
  63.     if (form.answer3)
  64.     size3 = form.answer3.selectedIndex;
  65.     if (form.answer4)
  66.     size4 = form.answer4.selectedIndex;
  67.     if (form.answer5)
  68.     size5 = form.answer5.selectedIndex;
  69.     if (form.answer6)
  70.     size6 = form.answer6.selectedIndex;
  71.  
  72.     RightAnswer1 = "6";
  73.     RightAnswer2 = "5";
  74.     RightAnswer3 = "4";
  75.     RightAnswer4 = "1";
  76.     RightAnswer5 = "2";
  77.     RightAnswer6 = "3";
  78.  
  79.     NumberCorrect = 0;
  80.     AnswerPage = 'stars_solution.html';
  81.     
  82.     if (size1 == RightAnswer1) {
  83.         NumberCorrect++;
  84.     }
  85.     if (size2 == RightAnswer2) {
  86.         NumberCorrect++;
  87.     }
  88.     if (size3 == RightAnswer3) {
  89.         NumberCorrect++;
  90.     }
  91.     if (size4 == RightAnswer4) {
  92.         NumberCorrect++;
  93.     }
  94.     if (size5 == RightAnswer5) {
  95.         NumberCorrect++;
  96.     }
  97.     if (size6 == RightAnswer6) {
  98.         NumberCorrect++;
  99.     }
  100.     
  101.     alert ("You answered " +NumberCorrect + " out of 6 questions correctly!");
  102.     location = AnswerPage; 
  103. }
  104.  
  105.     
  106.